//****************************************************************
//* Copyright (c) 2004 Ford Motor Company. All Rights Reserved.
//*
//* $$Workfile:   CatalogLogic.java  $$
//* $$Revision:   1.0  $$
//* $$Author:   aponte  $$
//* $$Date:   Dec 12 2008 13:24:12  $$
//*
//*****************************************************************
package ar.com.ford.it.fullEconomics.logic;

import java.sql.Timestamp;
import java.util.Collection;
import ar.com.ford.it.fullEconomics.FullEconomicsPrs;
import ar.com.ford.it.fullEconomics.exception.FullEconomicsException;
import ar.com.ford.it.fullEconomics.persistence.dao.CatalogDao;
import ar.com.ford.it.fullEconomics.persistence.dto.Ncas012VehicleVw;
import ar.com.ford.it.fullEconomics.persistence.dto.Ncas101CatalogVw;
import com.ford.it.logging.ILogger;
import com.ford.it.logging.Level;
import com.ford.it.logging.LogFactory;
import com.ford.it.persistence.PersistenceException;

public class CatalogLogic {

	private static final String CLASS_NAME = CatalogLogic.class.getName();

	private static final ILogger log = LogFactory.getInstance().getLogger(
			CLASS_NAME);

	/**
	 * Busco los catalogos que no tengan volumenes asociados
	 * 
	 * @param fechaIn
	 * @param fechaOut
	 * @return
	 * @throws PersistenceException
	 */
	public Collection<Ncas101CatalogVw> findCatalogWithoutVolume(
			Timestamp fechaIn, Timestamp fechaOut)
			throws FullEconomicsException {

		String METHOD_NAME = "findCatalogWithoutVolume";
		log.entering(CLASS_NAME, METHOD_NAME);

		Collection<Ncas101CatalogVw> res = null;

		try {
			res = (new CatalogDao())
					.findCatalogWithoutVolume(fechaIn, fechaOut);
		} catch (PersistenceException e) {
			log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
					"Find catalog without volume Exception", e);
			throw new FullEconomicsException(e,
					FullEconomicsPrs.MessageErrors.Catalog.FINDALL);
		}

		log.exiting(CLASS_NAME, METHOD_NAME);
		return res;
	}

	/**
	 * Busco los catalogos por vehiculo y fecha
	 * 
	 * @param ncas012VehicleVw
	 * @param fechaIn
	 * @param fechaOut
	 * @return
	 * @throws PersistenceException
	 */
	public Collection<Ncas101CatalogVw> findCatalogsByVehicleDate(
			Ncas012VehicleVw ncas012VehicleVw, Timestamp fechaIn,
			Timestamp fechaOut) throws FullEconomicsException {

		String METHOD_NAME = "findCatalogsByVehicleDate";
		log.entering(CLASS_NAME, METHOD_NAME);

		Collection<Ncas101CatalogVw> res = null;

		try {
			res = (new CatalogDao()).findCatalogsByVehicleDate(
					ncas012VehicleVw, fechaIn, fechaOut);
		} catch (PersistenceException e) {
			log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME,
					"Find catalog by vehicle date Exception", e);
			throw new FullEconomicsException(e,
					FullEconomicsPrs.MessageErrors.Catalog.FINDALL);
		}

		log.exiting(CLASS_NAME, METHOD_NAME);
		return res;
	}

}
